﻿using System;
using System.Globalization;
using System.Xml.Serialization;
using Renci.Data.Interop.OpenGIS.Exceptions;
namespace Renci.Data.Interop.OpenGIS.Wfs
{
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(TypeName = "GetCapabilitiesType", Namespace = "http://www.opengis.net/wfs")]
    [System.Xml.Serialization.XmlRootAttribute("GetCapabilities", Namespace = "http://www.opengis.net/wfs", IsNullable = false)]
    public class GetCapabilitiesType : Ows_11.GetCapabilitiesType
    {
        /// <summary>
        /// Holds service name support by the object
        /// </summary>
        private readonly string _service = "WFS";

        /// <summary>
        /// Initializes a new instance of the <see cref="GetCapabilitiesType"/> class.
        /// </summary>
        /// <remarks>Required for serialization.</remarks>
        public GetCapabilitiesType()
        {
            Init();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="GetCapabilitiesType"/> class.
        /// </summary>
        /// <param name="queryParameters">The query parameters to initialize the object with.</param>
        public GetCapabilitiesType(System.Collections.Specialized.NameValueCollection queryParameters)
            : base(queryParameters)
        {
            Init();

            this.UpdateSequence = queryParameters["updateSequence"];
        }

        /// <summary>
        /// Gets or sets prefix association with namespaces that are used object serializer.
        /// </summary>
        [XmlNamespaceDeclarations]
        public XmlSerializerNamespaces Xmlns { get; set; }

        /// <summary>
        /// Perfoms object initialization tasks
        /// </summary>
        private void Init()
        {
            this.Service = this._service;

            this.Xmlns = new XmlSerializerNamespaces();
            this.Xmlns.Add("ows", "http://www.opengis.net/ows");
            this.Xmlns.Add("ogc", "http://www.opengis.net/ogc");
            this.Xmlns.Add("wfs", "http://www.opengis.net/wfs");
            this.Xmlns.Add("gml", "http://www.opengis.net/gml");
            this.Xmlns.Add("xlink", "http://www.w3.org/1999/xlink");
            this.Xmlns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
        }

        /// <summary>
        /// Validates current instance and makes sure that all required properties are set and has corect value
        /// </summary>
        public override void Validate()
        {
            base.Validate();

            if (!this.Service.Equals(this._service, StringComparison.OrdinalIgnoreCase))
                throw new OptionNotSupportedException(string.Format(CultureInfo.CurrentCulture, "Service '{0}' is not supported.", this.Service));
        }
    }
}
